$(document).ready( function() {

    $('#username').blur( function () {

        fieldName = $(this).attr('id');
        fieldValue = $(this).val();

        $.post('http://localhost/cake/tvcable/users/ajax_validate', {
                                        field: fieldName,
                                        value: fieldValue
                                        },
               function(error) {

                   if(error.length != 0) {                

                       $('#username').after('<div class="error-message" id="'+ fieldName +'-exists">' + error + '</div>');
                   }
                   else {
                       $('#' + fieldName + '-exists').remove();
                   }
               });
     });   

});